%% -*- mode: erlang -*-
[
    {exometer_core, [
        {predefined, [
            {[erlang, memory], {function, erlang, memory, [], value, []}, []},
            {[erlang, system_info], {function, erlang, system_info, ['$dp'], value, [process_count]}, []},
            {[erlang, statistics], {function, erlang, statistics, ['$dp'], value, [run_queue]}, []},
            {[erlang, io], {function, erlang, statistics, [io], match, {{'_', input}, {'_', output}}}, []}
        ]}
    ]},

    {kernel, [
        % Minimum log level for all loggers below.
        {logger_level, info},

        {logger, [

            %% To use logstash:
            %% - Enable the logstasher_h handler
            %% - Configure logstasher (see below the kernel config)
            %%
            % {handler, logstash, logstasher_h,
            %     #{
            %         level => info
            %     }
            % },

            % Log of all information to the terminal/console.
            % The 'logger_level' above defines what is shown on the console.
            {handler, default, z_logger_h,
                #{
                    level => debug,
                    formatter => {z_logger_formatter,
                        #{
                            prettify => true,
                            colored => true,
                            time_designator => $\s,
                            time_offset => "",
                            time_unit => second,
                            strip_tz => true,
                            level_capitalize => true
                        }
                    }
                }
            },

            % Error log on disk.
            % LOG_DIR is replaced with the default Zotonic ZOTONIC_LOG_DIR directory.
            {handler, error_log, z_logger_h,
                #{
                    level => error,
                    config => #{
                        type => file,
                        file => "LOG_DIR/error.log",
                        max_no_files => 10,
                        max_no_bytes => 52428800 % 10 x 5mb
                    },
                    formatter => {z_logger_formatter,
                        #{
                            prettify => true,
                            colored => false,
                            time_designator => $\s,
                            time_offset => "",
                            time_unit => second,
                            strip_tz => true,
                            level_capitalize => true
                        }
                    }
                }
            },

            % Console log on disk.
            % LOG_DIR is replaced with the default Zotonic ZOTONIC_LOG_DIR directory.
            {handler, console_log, z_logger_h,
                #{
                    level => debug,
                    config => #{
                        type => file,
                        file => "LOG_DIR/console.log",
                        max_no_files => 10,
                        max_no_bytes => 52428800 % 10 x 5mb
                    },
                    formatter => {z_logger_formatter,
                        #{
                            prettify => true,
                            colored => false,
                            time_designator => $\s,
                            time_offset => "",
                            time_unit => second,
                            strip_tz => true,
                            level_capitalize => true
                        }
                    }
                }
            }
        ]}
    ]},

    %% Logstash configuration.
    %% If a logger handler with 'logstasher_h' is defined then zotonic_core will start the
    %% logstasher application.
    {logstasher, [
        {transport, console}, % tcp | udp | console
        {host, "localhost"},  % inet:hostname()
        {port, 5000}          % inet:port_number()
    ]},

    %% Emit a disk full warning above this threshold. Use a float between 0.0 and 1.0 (inclusive).
    {os_mon, [
        {disk_almost_full_threshold, 0.9}
    ]},

    %%% The directories below will be set according to the log_dir, data_dir and cache_dir

    % {setup, [
    %     {data_dir, "data"},
    %     {log_dir,  "logs"}
    % ]},

    % {filezcache, [
    %     {data_dir, "data/filezcache/data"},
    %     {journal_dir, "data/filezcache/journal"}
    % ]},

    % {mnesia, [
    %     {dir, setup}  % Use the config from setup -- handled by zotonic_core
    % ]},

    %% SSL application configuration.
    %%
    %% For details see: http://erlang.org/doc/man/ssl_app.html
    {ssl, [
        %% The max number of cached SSL parameters. Increase if you have a lot of clients
        %% connecting to your server.
        {session_cache_server_max, 20000},

        %% The amount of time the parameters are cached. (in seconds).
        {session_lifetime, 300}, % 5 minutes

        %% The time between pem cache cleanups (in milliseconds)
        {ssl_pem_cache_clean, 300000} % 5 minutes
    ]}
].
